layui.use(['jquery', 'table', 'laydate', 'form'], function(){
			var $ = layui.jquery,
				table = layui.table,
				laydate = layui.laydate,
				table2 = layui.table,
				form = layui.form;
			
		  initColumn = function () {
		        return [[
		        	{type:'numbers', fixed: 'left', title: '序号'},
		        	{field: 'tableName', sort: true, width:180,title: '表名' },
		            {field: 'tableComment', sort: true, width:180, title: '中文名称'},
		            {title:'操作', align: 'center',  minWidth: 68,fixed: 'right', templet: function(d){
		            	var tableName=d.tableName;
		            	var generatorTable ="generatorTable('" + tableName + "')";
		            	   var htmlStr="";
		            	   htmlStr+='<button type="button" onclick="'+ generatorTable + '" class="layui-btn layui-btn-xs layui-btn-normal">生成代码</button>';
			        	    return "<div>"+htmlStr+"</div>"
		            }}
		        ]];
		    };

		     search = function () {
		         var queryData = {};
		         queryData['tableName'] = "";
		         if($("#tablenameId").val()) {
		             queryData['tableName'] = $("#tablenameId").val();
		         }
		         table.reload('birthTable', {where: queryData});
		     };
		     
		 // 渲染表格
		    var tableResult = table.render({
		        elem: '#birthTable',
		        url: "/generator/querytablelist?v="+(new Date()).getTime(),
		        page : { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
			         limit: 15
			        ,layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
			        ,limits: [10,20,30,40,50]  //设置每页数据条数的选择项
			        ,groups: 5 //只显示 1 个连续页码
			        ,first: '首页' //显示首页  false不显示首页
				    ,last: '尾页' //显示尾页   false 不显示尾页
		        },
		        height: "full-89",
		        cellMinWidth: 20,
		        cols: initColumn()
		    });
		//监听行单击事件（单击事件为：rowDouble）
		table.on('row(birthTable)', function(obj){
			
		    var tableName = obj.data.tableName;
		 
		    var queryData = {};
		    queryData['tableName'] = tableName;
		    table2.render({
		       elem: '#birthTableInfo'
		      , url: '/generator/querycolumnslist?v='+(new Date()).getTime()
		      , where: queryData
		      ,cellMinWidth: "full-19" //全局定义常规单元格的最小宽度，layui 2.2.1 新增
		      ,height: "full-89"
		      ,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
		          layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
		          ,limit: 100
		          ,groups: 5 //只显示 1 个连续页码
		          ,first: false //不显示首页
		          ,last: false //不显示尾页
		        }
		      ,cols: [[
		    		{type:'numbers', fixed: 'left', title: '序号'},
		            {field: 'columnName', title: ' 列 名 ', width:160, align: 'center'},
		            {field: 'columnType', title: '列类型与长度', width: 150, align: 'center'},
		            {field: 'columnKey', title: ' 主 键 ', width: 100, align: 'center'},
		           //{field: 'extra', title: 'extra', width: 100, align: 'center'},
		            {field: 'columnComment', title: '备注与说明', width: 160, align: 'center'} 
		      ]]
		    });
		   
		});
		 
});
function generatorTable(tableName){
	location.href = "/generator/generatorTable?tableName=" + tableName;
}
function excelWriterTest(){
	location.href = "http://localhost:8900/v2/task/record/excel?startTime=2021-07-28%2016:38:59&endTime=2021-08-30%2016:38:59";
}


function excelWriter(tableName){
	location.href = "/excle/excelWriter";
}